import math
import copy

import numpy as np
import torch
#
# am = torch.exp(torch.arange(0, 100, 2) * -(math.log(10000) / 100))
# print(am)
# print(am.shape)
#
#
# a2 = torch.Tensor(range(1, 21))
# a2 = a2.reshape((4, 5))
# # a2 = a2.unsqueeze(0)
# print(a2)
# print(a2.shape)
#
# print(np.triu(a2, k=-1))
# print('-'*50)
# print(np.triu(a2, k=1))
# print('-'*50)
# print(np.triu(a2, k=0))

r1 = torch.randn(5, 5)
r2 = np.triu(torch.ones(5, 5), k=1)
print(r2)
r2 = torch.from_numpy(r2)
r1 = r1.masked_fill(r2 == 0, 1e-9)
print(r1)
print('-'*50)

r3 = torch.randn(3, 4)
print(r3)
# torch.view()
print('-'*50)
q, k, v = torch.randn(4, 3),torch.randn(4, 3),torch.randn(4, 3)
print(q, k, v)
print('-'*50)

m = [lambda x:x*1, lambda x:x*2, lambda x:x*3, lambda x:x*4]
print(m[0](3))
print(m[1](3))
print(m[2](3))
print(m[3](3))
result = [model(x) for model, x in zip(m, (q, k, v))]
print(result[0])


a = torch.Tensor(range(2000))
print(a.shape)
a = a.reshape(200, -1)
print(a.shape)
a = a.view(50, -1)
print(a.shape)

a = a.transpose(1, 0)
print(a.shape)
